<template>
  <div>
    <el-tabs style='margin-top:0px;' type="border-card" v-model="activeName">
      <el-tab-pane :label='MapOptions[0].label' :name='MapOptions[0].key'>
        <keep-alive>
          <el-container>
            <el-aside width="25%">
              <a>所有权限</a>
              <tree-list @change="information" ref="treeList"></tree-list>
            </el-aside>
          </el-container>
        </keep-alive>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
  import {
    getRightIDListByRole,
  } from '@/api/user';
  import treeList from './comp_tree';
  export default {
    props:{
      viewCode:{type:Array}
    },
    components: {
      treeList,
    },
    data() {
      return {
        MapOptions: [{
          label: ' 所有权限',
          key: 't0'
        }],
        activeName: 't0',
        rightdata: {
          system: [], 
        },
      };
    },
    methods: {
      GetRightIDListByRole(roleid) { //取当前角色所有权限 
        this.rightdata.system = [],
        getRightIDListByRole(roleid).then(rsp => {
          let data=rsp.data;
          data.forEach(item => {
            this.rightdata.system.push(item);
            console.log(this.rightdata.system);
          });
          this.$refs.treeList.setCheckedKeys(this.rightdata.system); 
        });

        /* setTimeout(() => {
          getAddReadyData().then(rsp => { //获取角色等级
            this.addReadyData.level = rsp.data.level;
          });
        }, 600); */
      },
      system(value) { //系统管理
        this.dlgRecord.system = value;
        this.$emit('change', this.dlgRecord);
      },

      Thevalue(id) { //接收index的数据ID     
        if (id != 0) {
          this.$refs.treeList.TreeRefresh(id);
          setTimeout(() => {
            this.GetRightIDListByRole(id);
          }, 600); 
        }
      },
      information(value) { 
        this.rightdata.system = value;
        this.$emit('change', this.rightdata);
      },
      empty() //每一轮都要初始化
      {
        this.rightdata = {
          system: [], 
          Class: 0,
        };
      },
      call() { //保存
        console.log('call');
        setTimeout(() => {
          this.$refs.treeList.getCheckedKeys();
        }, 200); //基本操作
      }
    },
  };

</script>

<style lang="scss" scoped>
.TS{
  color:#1e1e8f;
}
</style>
